package com.xydtech.ecard.custgroup.service.impl;

import com.xydtech.common.utils.AESEncryptionUtils;
import com.xydtech.common.utils.StringUtils;
import com.xydtech.ecard.custgroup.domain.EcardApiCustomerOrganizeTask;
import com.xydtech.ecard.custgroup.mapper.EcardApiCustomerOrganizeTaskMapper;
import com.xydtech.ecard.custgroup.service.IEcardApiCustomerOrganizeTaskService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 电子名片社团组织任务Service业务层处理
 *
 * @author yuzhiguo
 * @date 2024-11-29 下午1:23
 */
@Service
public class EcardApiCustomerOrganizeTaskServiceImpl implements IEcardApiCustomerOrganizeTaskService {

    @Autowired
    private EcardApiCustomerOrganizeTaskMapper ecardCustomerOrganizeTaskMapper;

    /**
     * 新增电子名片社团组织任务
     * @param ecardCustomerOrganizeTask 电子名片社团组织任务
     * @return
     */
    @Override
    public int insertEcardCustomerOrganizeTask(EcardApiCustomerOrganizeTask ecardCustomerOrganizeTask) {
        return ecardCustomerOrganizeTaskMapper.insertEcardCustomerOrganizeTask(ecardCustomerOrganizeTask);
    }

    /**
     * 查询电子名片社团组织任务记录列表
     * @param cmRegistId
     * @param search
     * @param deptId
     * @param phone
     * @param salt
     * @return
     */
    @Override
    public List<EcardApiCustomerOrganizeTask> getOrganizeTaskList(Long cmRegistId, String search, Long deptId, String phone, String organizeType, String salt) {
        try {
            //数据加密（手机号、身份证号）
            if (!StringUtils.objIsNullOrEmpty(phone)) {
                phone = (AESEncryptionUtils.encrypt(phone, salt));
            }
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
        return ecardCustomerOrganizeTaskMapper.getOrganizeTaskList(cmRegistId,search,deptId,phone,organizeType);
    }
}
